var e, t = (e = require("@vant/weapp/toast/toast")) && e.__esModule ? e : {
    default: e
};

var a = require("../../utils/request"), i = require("../../utils/api"), s = require("../../utils/check");

Page({
    data: {
        themeColor: getApp().globalData.themeColor,
        active: 0,
        name: "",
        certNo: "",
        checkCenterMobile: "",
        smsCode: "",
        voucherNo: "",
        password: "",
        second: 60,
        disabled: !1,
        sendTxt: "发送验证码",
        sliderVerifyPopupShow: !1
    },
    onChange: function(e) {
        this.setData({
            active: e.detail.name
        });
    },
    searchReport: function() {
        if (0 == this.data.active) {
            if ("" == this.data.name.replace(" ", "")) return void (0, t.default)({
                message: "请输入体检人姓名",
                duration: 5e3
            });
            if ("" == this.data.checkCenterMobile.replace(" ", "")) return void (0, t.default)({
                message: "请输入预留手机号",
                duration: 5e3
            });
            if ("" == this.data.smsCode.replace(" ", "")) return void (0, t.default)({
                message: "请输入短信验证码",
                duration: 5e3
            });
            wx.navigateTo({
                url: "/pages/my-link-report-search-result/my-link-report-search-result?active=".concat(this.data.active, "&name=").concat(this.data.name, "&certNo=").concat(this.data.certNo, "&checkCenterMobile=").concat(this.data.checkCenterMobile, "&smsCode=").concat(this.data.smsCode)
            });
        } else {
            if ("" == this.data.voucherNo.replace(" ", "")) return void (0, t.default)({
                message: "请输入报告查询账号",
                duration: 5e3
            });
            if ("" == this.data.password.replace(" ", "")) return void (0, t.default)({
                message: "请输入报告查询密码",
                duration: 5e3
            });
            wx.navigateTo({
                url: "/pages/my-link-report-search-result/my-link-report-search-result?active=".concat(this.data.active, "&voucherNo=").concat(this.data.voucherNo.replace(" ", ""), "&password=").concat(this.data.password.replace(" ", ""))
            });
        }
    },
    sendMess: function() {
        "" != this.data.checkCenterMobile.replace(" ", "") ? s.isMobile(this.data.checkCenterMobile.replace(" ", "")) ? this.setData({
            sliderVerifyPopupShow: !0
        }) : (0, t.default)({
            message: "手机号格式不正确",
            duration: 5e3
        }) : (0, t.default)({
            message: "请输入预留手机号",
            duration: 5e3
        });
    },
    onVerify: function(e) {
        0 == e.detail.msg ? (0, t.default)({
            message: "验证失败，请重试",
            duration: 1500
        }) : (this.setData({
            sliderVerifyPopupShow: !1
        }), this.timer());
    },
    onSliderVerifyPopupClose: function() {
        this.setData({
            sliderVerifyPopupShow: !1
        });
    },
    timer: function() {
        var e = this;
        this.setData({
            disabled: !0
        }), a.request(a.HttpMethod.GET, i.apiRoute.sendVerificationCode + "?mobile=" + this.data.checkCenterMobile, {}).then(function(e) {
            "20000" !== e.code && ((0, t.default)({
                message: e.message,
                duration: 5e3
            }), wx.hideLoading());
        }), new Promise(function(t) {
            var a = setInterval(function() {
                e.setData({
                    second: e.data.second - 1
                }), e.data.second <= 0 && (e.setData({
                    second: 60,
                    disabled: !1
                }), t(a));
            }, 1e3);
        }).then(function(e) {
            clearInterval(e);
        });
    }
});